package com.yihen.mappers;

import com.yihen.dto.SimpleUseDTO;
import com.yihen.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {
    // 查找单个用户(手机)
    @Select("select * from tb_user where phone_number=#{phone}")
    public User queryUserByPhone(String phone);

    // 查找单个用户(id)
    @Select("select * from tb_user where user_id=#{id}")
    public User queryUserById(Long id);

    // 修改用户密码

    public int updatePassword(Long userId, String newpassword);


    // 查询所有用户
    @Select("select * from tb_user ")
    public List<User> queryUser();

    // 新增用户
    @Insert("insert into tb_user values (#{userId},#{username},#{password},#{gender},#{email},#{phoneNumber},#{level},#{profile})")
    public int inertUser(User user);

    // 修改用户权限
    public int updateUserLevel(int level,Long userId);

    // 删除用户
    @Delete("delete from tb_user where user_id=#{userId}")
    public int deleteUserById(Long userId);

    // 修改用户信息
    public int updateUser(User user);

    // 批量查询用户
    public List<SimpleUseDTO> selectUsersByIds(List<Long> ids);
}
